package info.johnwheeler.gaestorage.core;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Id;

import com.googlecode.objectify.Key;

public class Document {

	@Id
	private Long id;
	private String title;
	private String caption;
	private String contentType;
	private byte[] documentData;
	private String documentPath;
	Key<Person> solicitationOwnerKey;
	private Person owner;
	Key<Person> authorKey;
	private Person author;
	private String county;
	private String processNumber;
	private Date deadLine;
	private String description;

	public Document(String title, String caption) {
		super();
		this.title = title;
		this.caption = caption;
	}

	public Document() {

	}

	public Key<Person> getSolicitationOwnerKey() {
		return solicitationOwnerKey;
	}

	public void setSolicitationOwnerKey(Key<Person> solicitationOwnerKey) {
		this.solicitationOwnerKey = solicitationOwnerKey;
	}

	public Person getOwner() {
		return owner;
	}

	public void setOwner(Person owner) {
		this.owner = owner;
	}

	public Key<Person> getAuthorKey() {
		return authorKey;
	}

	public void setAuthorKey(Key<Person> authorKey) {
		this.authorKey = authorKey;
	}

	public Person getAuthor() {
		return author;
	}

	public void setAuthor(Person author) {
		this.author = author;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getCaption() {
		return caption;
	}

	public void setCaption(String caption) {
		this.caption = caption;
	}

	public byte[] getDocumentData() {
		return documentData;
	}

	public void setDocumentData(byte[] documentData) {
		this.documentData = documentData;
	}

	public String getDocumentPath() {
		return documentPath;
	}

	public void setDocumentPath(String documentPath) {
		this.documentPath = documentPath;
	}

	public String getProcessNumber() {
		return processNumber;
	}

	public void setProcessNumber(String processNumber) {
		this.processNumber = processNumber;
	}

	public Date getDeadLine() {
		return deadLine;
	}

	public void setDeadLine(Date deadLine) {
		this.deadLine = deadLine;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	/*
	 * public Key<Person> getSolicitationOwner() { return solicitationOwner; }
	 * 
	 * public void setSolicitationOwner(Key<Person> person) {
	 * this.solicitationOwner = person; }
	 */
	public void setId(long id) {
		this.id = id;
	}

	/*
	 * public Key<Person> getAuthor() { return author; }
	 * 
	 * public void setAuthor(Key<Person> author) { this.author = author; }
	 */
	public String getCounty() {
		return county;
	}

	public void setCounty(String county) {
		this.county = county;
	}

	public String getDeadLineToString() {
		SimpleDateFormat formatBra;
		formatBra = new SimpleDateFormat("dd/MM/yyyy");
		try {
			java.util.Date newData = formatBra.parse(deadLine.toString());
			return (formatBra.format(newData));
		} catch (ParseException Ex) {
			return "Erro na conversão da data";
		}

	}

	@Override
	public String toString() {
		return "document [id=" + id + ", title=" + title + ", caption="
				+ caption + ", contentType=" + contentType + ", documentPath="
				+ documentPath + "]";
	}

}
